﻿
Public Class windowopen
    Public Const functionName As String = "wnp"

    Public Shared Sub register(ByVal inlineScript As inlineScript)
        assert(Not inlineScript Is Nothing, "inlineScript is nothing.")
        inlineScript.addscript("window.open", "function " + functionName + "(u){" + _
                               window.name(inlineScript) + ".open(u);}")
    End Sub

    Public Shared Function invoke(ByVal inlineScript As inlineScript, ByVal url As String, _
                                  Optional ByRef actionTarget As String = Nothing) As String
        If Not inlineScript Is Nothing Then
            register(inlineScript)
        End If

        actionTarget += functionName + "(" + url + ")"
        Return actionTarget
    End Function
End Class

Public Class locationhref
    Public Const functionName As String = "lrf"

    Public Shared Sub register(ByVal inlineScript As inlineScript)
        assert(Not inlineScript Is Nothing, "inlineScript is nothing.")
        inlineScript.addscript("location.href", "function " + functionName + "(u){" + _
                               window.name(inlineScript) + ".location=u;}")
    End Sub

    Public Shared Function invoke(ByVal inlineScript As inlineScript, ByVal url As String, _
                                  Optional ByRef actionTarget As String = Nothing) As String
        If Not inlineScript Is Nothing Then
            register(inlineScript)
        End If

        actionTarget += functionName + "(" + url + ")"
        Return actionTarget
    End Function
End Class